home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLSRC.PAK / ICON.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.1 KB  |  108 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.7  $
  6. //
  7. // Implementation of class TIcon, a GDI Icon object encapsulation
  8. //----------------------------------------------------------------------------
  9. #include <owl/pch.h>
  10. #if !defined(OWL_GDIOBJEC_H)
  11. # include <owl/gdiobjec.h>
  12. #endif
  13.  
  14. OWL_DIAGINFO;
  15. DIAG_DECLARE_GROUP(OwlGDI);        // General GDI diagnostic group
  16.  
  17. //
  18. //
  19. //
  20. TIcon::TIcon(HICON handle, TAutoDelete autoDelete)
  21. :
  22.   TGdiBase(handle, autoDelete)
  23. {
  24. }
  25.  
  26. #if defined(BI_PLAT_WIN32)
  27. //
  28. //
  29. //
  30. TIcon::TIcon(HINSTANCE, const TIcon& icon)
  31. {
  32.   Handle = ::CopyIcon(icon);
  33.   CheckValid();
  34. }
  35. #else
  36. //
  37. //
  38. //
  39. TIcon::TIcon(HINSTANCE instance, const TIcon& icon)
  40. {
  41.   Handle = ::CopyIcon(instance, icon);
  42.   CheckValid();
  43. }
  44. #endif
  45.  
  46. //
  47. //
  48. //
  49. TIcon::TIcon(HINSTANCE instance, TResId resId)
  50. {
  51.   Handle = ::LoadIcon(instance, resId);
  52.   ShouldDelete = (instance != 0);
  53.   CheckValid();
  54. }
  55.  
  56. //
  57. //
  58. //
  59. TIcon::TIcon(HINSTANCE instance, const char far* fileName, int index)
  60. {
  61.   Handle = ::ExtractIcon(instance, (LPSTR)fileName, index);
  62.   if ((int)Handle == 1)
  63.     Handle = 0;
  64.   CheckValid();
  65. }
  66.  
  67. //
  68. //
  69. //
  70. TIcon::TIcon(HINSTANCE instance, const TSize& size, int planes, int bitsPixel,
  71.              const void far* andBits, const void far* xorBits)
  72. {
  73.   Handle = ::CreateIcon(instance, size.cx, size.cy,
  74.                         uint8(planes), uint8(bitsPixel),
  75.                         (const uint8 far*)andBits, (const uint8 far*)xorBits);
  76.   CheckValid();
  77. }
  78.  
  79. #if defined(BI_PLAT_WIN32)
  80. //
  81. //
  82. //
  83. TIcon::TIcon(const void* resBits, uint32 resSize)
  84. {
  85.   Handle = CreateIconFromResource((PBYTE)resBits, resSize, true, 0x00030000);
  86.   CheckValid();
  87. }
  88.  
  89. //
  90. //
  91. //
  92. TIcon::TIcon(const ICONINFO* iconInfo)
  93. {
  94.   //IconInfo->fIcon = true;  // assume the user setup the struct OK
  95.   Handle = CreateIconIndirect((PICONINFO)iconInfo);
  96.   CheckValid();
  97. }
  98. #endif
  99.  
  100. //
  101. //
  102. //
  103. TIcon::~TIcon()
  104. {
  105.   if (ShouldDelete && Handle)
  106.     ::DestroyIcon((HICON)Handle);
  107. }
  108.